
--[[

    slimui - Copyright (c) 2011 atom0s, All rights reserved.

    See Copyright notice in slimui.lua
    
]]--

class 'Edit: WinControl' { ... };

----------------------------------------------------------------------------------
-- func: Edit.__init__
-- desc: Constructor called when this object is first created.
----------------------------------------------------------------------------------
function Edit.__init__( self )
    WinControl.__init__( self );
end

----------------------------------------------------------------------------------
-- func: Edit:Create
-- desc: Creates a new edit object.
----------------------------------------------------------------------------------
function Edit:Create( parent )
    if parent == nil or parent._object == nil then
        slimui:err( 'Edit:Create - parent must be set to create a control!' );
    end
    
    self._object = createEdit( parent._object );
    
    if self._object == nil then
        slimui:err( 'Edit:Create - failed to initialize a new object.' );
    end
    
    return self;
end

----------------------------------------------------------------------------------
-- func: Edit:Clear
-- desc: Clears all the text in this edit control.
----------------------------------------------------------------------------------
function Edit:Clear( )
    edit_clear( self._object );
end

----------------------------------------------------------------------------------
-- func: Edit:SelectAll
-- desc: Selects all the text in this edit control.
----------------------------------------------------------------------------------
function Edit:SelectAll( )
    edit_selectAll( self._object );
end

----------------------------------------------------------------------------------
-- func: Edit:ClearSelection
-- desc: Removes the current select in this edit control.
----------------------------------------------------------------------------------
function Edit:ClearSelection( )
    edit_clearSelection( self._object );
end

----------------------------------------------------------------------------------
-- func: Edit:Copy
-- desc: Copies the current selected text to the clipboard.
----------------------------------------------------------------------------------
function Edit:Copy( )
    edit_copyToClipboard( self._object );
end

----------------------------------------------------------------------------------
-- func: Edit:Cut
-- desc: Cuts the current selected text to the clipboard.
----------------------------------------------------------------------------------
function Edit:Cut( )
    edit_cutToClipboard( self._object );
end

----------------------------------------------------------------------------------
-- func: Edit:Paste
-- desc: Pastes the clipboards contents to this edit control.
----------------------------------------------------------------------------------
function Edit:Paste( )
    edit_pasteFromClipboard( self._object );
end

----------------------------------------------------------------------------------
-- func: Edit:OnChange
-- desc: Sets the OnChange event handler for this edit control.
----------------------------------------------------------------------------------
function Edit:OnChange( func )
    edit_onChange( self._object, func );
end



--[[ Debug information. ]]--------------------------------------------------------
if ( slimui:isdebug() == true ) then
    slimui:msg( '(Control) edit.lua successfully loaded.' );
end